<#assign pageTitle = "收货地址" />
<#assign pageHeader>
    <style>
        .fsize14{margin-bottom: 10px}
    </style>
    <script type="text/javascript">
        function delConfirm(id) {
            return layer.confirm("确认要删除此条站内信吗？", {
                icon: 3,
                title: "系统提示",
                btn: ['确认', '取消']
            }, function (index) {
                layer.close(index);
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: "/user/ajax/delLetterInbox",
                    data: {"id": id},
                    cache: true,
                    success: function (result) {
                        if (result.code === 0) {
                            layer.msg("删除成功", {time: 1000});
                            window.location.reload()
                        } else {
                            layer.msg(result.msg, {time: 3000});
                        }
                    }
                });
            });
        }
    </script>
</#assign>
<#assign pageContent>
    <article class="w80 fl">
        <div class="u-r-cont">
            <section>
                <div class="">
                    <section class="u-r-tit-all clearfix">
                        <h2 class="unFw fl">
                            <span class="current">收货地址</span>
                        </h2>
                        <section class="u-o-right fr tar mr20 mt13">
                            <a class="cou-kscp" href="javascript:void (0)" onclick="editAddress(0)"  title="添加地址"><i class="layui-icon layui-icon-add-1"></i>添加地址</a>
                        </section>
                    </section>
                    <div class="u-r-all-box">
                        <#if addressList?? && addressList?size gt 0>
                            <div class="u-sys-news">
                                <ul class="u-sys-list">
                                    <#list addressList as tiem>
                                        <li id="del${tiem.id }">
                                            <div>
                                                <section class="" style="color: #666666;margin-top: 5px">
                                                    <p class="fsize14">
                                                        <strong style="margin-right: 50px">收件人：${tiem.userName!}</strong>
                                                        <strong>电话：${tiem.mobile!}</strong>
                                                        <a href="javascript:void (0)" onclick="delAddress(${tiem.id!})" title="删除" class="layui-btn layui-btn-primary layui-btn-xs" style="float: right">
                                                            删除
                                                        </a>
                                                        <a href="javascript:void (0)" onclick="editAddress(${tiem.id!})" title="编辑" class="layui-btn layui-btn-danger layui-btn-xs" style="float: right;margin-right: 5px">
                                                            编辑
                                                        </a>
                                                    </p>
                                                    <p class="fsize14">
                                                        <strong>地区：${tiem.province!}</strong>
                                                    </p>
                                                    <p class="fsize14">
                                                        <strong>详细地址：${tiem.address!}</strong>
                                                    </p>

                                                </section>
                                            </div>
                                        </li>
                                    </#list>
                                </ul>
                            </div>
                        <#else>
                            <section class="no-data-wrap">
                                 <em class="icon30 no-data-ico">&nbsp;</em> <span class="c-666 fsize14 ml10 vam">您还没有收货地址，快去<a href="javascript:void(0)" onclick="editAddress(0)" class="c-master f-fM fsize14">创建一个</a>吧！</span>
                             </section>
                        </#if>
                    </div>
                </div>
            </section>
            <!-- /Wo的消息 -->
        </div>
    </article>
    <!-- /右侧内容区 结束 -->
</#assign>
<#assign pageFooter>
</#assign>
<#include "../layouts/layout_uc.ftl">
<script type="text/javascript">

    function editAddress(id) {
        layer.open({
            type: 2,
            title: null,
            area: ['660px', '400px'],
            content: '/user/address/edit.html?id=' + id
        });
    }

    function delAddress(id) {
        layer.confirm('确定要删除该地址吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("/user/address/remove.json",{"id":id},function (json) {
                if(json.code === 0){
                    window.location.reload();
                }else {
                    layer.msg(json.msg, {icon: 2});
                }

            })
        });
    }
</script>

